<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>

    let s1 = Symbol('foo'),
        s2 = Symbol('bar'),
        s3 = Symbol('baz'),
        s4 = Symbol('qux');
    let o = {
        [s1]: 'foo val'
    };
    // 这样也可以:o[s1] = 'foo val';
    console.log(o);
    // {Symbol(foo): foo val}
    Object.defineProperty(o, s2, {value: 'bar val'});
    console.log(o);
    // {Symbol(foo): foo val, Symbol(bar): bar val}
    Object.defineProperties(o, {
        [s3]: {value: 'baz val'}, [s4]: {value: 'qux val'}
    });
    console.log(o);
    // {Symbol(foo): foo val, Symbol(bar): bar val, // Symbol(baz): baz val, Symbol(qux): qux val}

    o.name = '张三';
    o.__proto__.age = 12;
    o.__proto__[s1] = 'Symbol-s1'
    console.log('赋值后的o',o)
    // todo:Object 记笔记
    // 获取自身
    console.log(Object.getOwnPropertyNames(o))  // 返回对象实例的常规属性数组  ['name']
    // Object.getOwnPropertySymbols()返回对象实例的符号属性数组
    console.log(Object.getOwnPropertySymbols(o))  // 4个symbol组成的数组  []
    console.log(Object.getOwnPropertyDescriptors(o)) // 返回同时包含常规和符号属性描述符的对象 {}
    console.log(Reflect.ownKeys(o))  //返回两种类型 的键:[]
    // Object.keys();

    // 获取原型上的
    console.log(Object.getPrototypeOf(o)) // 获得原型上的两个属性,返回对象

    // 获取全部非symbol的
    console.log(o)
    for(let filed in o){
        console.log(filed) // name,age
    }
</script>
</body>
</html>